controller_dialogos = function(){
	
	//init_UI_dialogos();
	
	//INIT: funcion de inicilizacion: crea el dialogo generico
	(function(){
		$('<div>').attr("id","getLinkDiag").attr("class","dialog-modal").attr("title","Link de la Busqueda").appendTo($(document.body));
		$( "#getLinkDiag" ).dialog({	
			modal: true,
			width: 450,
			autoOpen: false,
			resizable: false,
			buttons: {	Ok: function() {$( this ).dialog( "close" );}},
			close: function(event, ui) {DIALOG_MANAGER.openedDialog();},
			open: function(event, ui) {DIALOG_MANAGER.closedDialog();},	
		});
		
		$("#dialogoConfig").hide();
	})();
	
	var dialogosAbiertos = 0;
	this.openedDialog = function(){dialogosAbiertos++;};
	this.closedDialog = function(){dialogosAbiertos--;};
	
	//la camara pregunta si hay algun dialog abierto, en cuyo caso, deshabilita el movimiento de la camara
	this.algunDialogoAbierto = function(){	return dialogosAbiertos;};
	
	
	//---------------------------------------------------------------------------------------------------------------------
	//---------------------------------------------------------------------------------------------------------------------
	//---------------------------------------------------------------------------------------------------------------------
	//----------------------------------------------- DIALOGO GENERICO ----------------------------------------------------
	//---------------------------------------------------------------------------------------------------------------------
	//---------------------------------------------------------------------------------------------------------------------
	//---------------------------------------------------------------------------------------------------------------------
	var _domGenericDialog = $('<div>')
								.attr("class","dialog-modal")
								.attr("title","Ayuda")
								.appendTo($(document.body))
								.dialog({	
										modal: true,
										width: 400,
										autoOpen: false,	
										buttons: {	Ok: function() {$( this ).dialog( "close" );}},
										close: function(event, ui) {DIALOG_MANAGER.openedDialog();},
										open: function(event, ui) {DIALOG_MANAGER.closedDialog();}	
								});
	
	
	var _domDialogControlers = $("#dialogoControles").attr("class","dialog-modal")
										.dialog({	
												//modal: true,
												autoOpen: false,	
												buttons: {	Ok: function() {$( this ).dialog( "close" );}},
												//close: function(event, ui) {DIALOG_MANAGER.openedDialog();},
												//open: function(event, ui) {DIALOG_MANAGER.closedDialog();}	
										});;
	
	//funcion para mostrar dialogos genericos (que solo muestan texto)
	this.showMessage = function(target, mensaje){
	    $(_domGenericDialog).html(mensaje);
	    setupDialogo(target, _domGenericDialog);
	 
	};
	
	this.showControlers = function(target){
		var domDialog = _domDialogControlers;
		var pos = getDialogPosition(target);
	    $(domDialog).dialog( "widget" ).addClass("textFont");
		$(domDialog).dialog( "option", "position", [pos.x, pos.y]);
		$(domDialog).dialog( "open" );
		// setupDialogo(target, _domDialogControlers);
	};
	
	//posiciona el dialogo pegado al elemento que genero el evento, y abre el dialogo
	function setupDialogo(target, domDialog){
		   var pos = getDialogPosition(target);
		    $(domDialog).dialog( "widget" ).addClass("textFont");
			$(domDialog).dialog( "option", "position", [pos.x, pos.y]);
			$(domDialog).dialog( "open" );
			$(domDialog).dialog( "widget" ).css('width','auto');
			$(domDialog).dialog( "widget" ).css('text-align','left');
	}
	
	//retorna las coordenadas para posicionar al dialogo (a la derecha del target)
	//return {x, y}
	function getDialogPosition(nodo){
		var position = $(nodo).offset(); 
		var x = position.left + $(nodo).outerWidth();
	    var y = position.top - $(document).scrollTop();
	    return {x: x, y: y};
	};
	
};